package com.xsd.awen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xsd.awen.domain.entity.User;
import com.xsd.awen.domain.po.UserPagePo;
import com.xsd.awen.domain.vo.UserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("<script> " +
            " select u.* from t_tk_user u " +
            " where 1=1 " +
            "<if test=\"user.name != null and user.name != ''\"> and u.name like CONCAT('%', #{user.name}, '%')</if>" +
            "<if test=\"user.gs != null and user.gs != ''\"> and u.gs = #{user.gs}</if>" +
            " order by u.create_time desc " +
            "</script>")
    List<UserPagePo> page(UserVo userVo);

    @Select(" select count(1) from t_tk_user where name = #{name} ")
    Integer countUser(User user);

    @Select(" select count(1) from t_tk_user where name = #{name} and id != #{id} ")
    Integer countUpdateUser(User user);

    @Select(" select * from t_tk_user where code = #{code} ")
    User getUserByUsername(User user);

}